package org.dlx.drpc.common;

import org.dlx.drpc.core.server.IRPCHandler;

//服务端处理 指数请求
public class ExpRequestHandler implements IRPCHandler
{
    @Override
    public Object handle(Object msg) throws Exception{
        ExpRequest message = (ExpRequest) msg;
        int base = message.getBase();
        int exp = message.getExp();
        long start = System.nanoTime();
        long res = 1;
        for (int i = 0; i < exp; i++) {
            res *= base;
        }
        long cost = System.nanoTime() - start;
        return  new ExpResponse(res, cost);
    }
}
